package com.edoomath.api.dao;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.edoomath.entity.usercourse.DownloadType;
import com.edoomath.entity.usercourse.UserCourseMaterial;
import com.edoomath.entity.usercourse.UserCourseMaterialCategory;

/**
 * 
 * @author mohanlan
 *
 */
@Dao(value = "hibernate")
public interface UserCourseMaterialDao {
	
	/**
	 * 
	 * @param unionid
	 * @param type
	 * @param originFileName
	 * @return
	 */
	@Query("FROM UserCourseMaterial WHERE unionid = :unionid AND downloadType = :type AND originFileName = :originFileName AND disabled = false")
	public UserCourseMaterial loadUserCourseMaterial(@Variable("unionid") String unionid,  @Variable("type") DownloadType type, @Variable("originFileName") String originFileName);
	
	/**
	 * 
	 * @param unionid
	 * @param materialIds
	 * @param today
	 * @return
	 */
	@Query("FROM UserCourseMaterial WHERE unionid = :unionid AND downloadType = :type AND courseMaterail.id in (:materialIds) AND disabled = false")
    public List<UserCourseMaterial> listMaterials(@Variable("unionid") String unionid,  @Variable("type") DownloadType type, @Variable("materialIds") List<Long> materialIds);
	
	/**
	 * 
	 * @param unionid
	 * @return
	 */
	@Query("FROM UserCourseMaterialCategory WHERE unionid = :unionid AND disabled = false")
	public List<UserCourseMaterialCategory> listUserCourseMaterialCategory(@Variable("unionid") String unionid);
	
}
